<?php //echo "<pre>"; die(print_r($data));?>
<div class="breadcrumbwidget">
	<ul class="skins">
        <li><a href="default" class="skin-color default"></a></li>
        <li><a href="orange" class="skin-color orange"></a></li>
        <li>&nbsp;</li>
        <li class="fixed"><a href="" class="skin-layout fixed"></a></li>
        <li class="wide"><a href="" class="skin-layout wide"></a></li>
    </ul><!--skins-->
	<ul class="breadcrumb">
        <li><a href="<?php echo $baseurl?>">Trang chủ</a> <span class="divider">/</span></li>
        <li class="active">Báo cáo</li>
    </ul>
</div><!--breadcrumbwidget-->
<div class="pagetitle">
	<h1>Báo cáo sử dụng mã quà tặng</h1> <span></span>
</div>
<div class="maincontent">
    <div class="contentinner">    
    
        <div id="dyntable_length" class="dataTables_length  content-dashboard">
            <button id="report" class="btn btn-success" type="button">Xuất báo cáo</button>
            
            <div style="position: absolute;top: 25px;right: 30px"><?php echo $fview->advancedSelectType($arrRestaurant, $selected, 'restaurant_id', 'Chọn nhà hàng'); ?></div>
        </div>
    	<table class="table table-bordered">
            <colgroup>
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
                <col class="con1" />
                <col class="con0" />
            </colgroup>
            <thead>
                <tr style="background-color: rgba(0,0,0,.1);">
                    <td colspan="9" style="text-align: center;font-size: 18px;"><?php //echo 'Tên E-coupon: '.$info->title;?></td>
                </tr>
                <tr>
                    <th style="width: 8%;">STT</th>
                    <th>Tên nhân viên</th>
					<th>Mã quà tặng</th>
					<th>Ca</th>
                    <th>Khách hàng</th>
                    <th>Ngày nhận</th>
                    <th>Ngày sử dụng</th>
                    <th>Quà tặng</th>
                    <th>Nhà hàng</th>
                    <th>Số hóa đơn</th>
					<th>Số khách</th>
					<th>Doanh thu</th>
                </tr>
            </thead>
            <tbody>
            <?php $i=1; if(!in_array($data, array(null, '', '0'))):?>
            <?php foreach($data AS $el=>$le):?>
                <tr>
                    <td><?php echo $per_page * $pageg + $i;?></td>
                    <th><?php echo $le->fullname;?></th>
					<td><?php echo $le->code_user?></td> 
					<th><?php echo $le->work_car;?></th>
					<td><?php echo $le->customer;?></td>
                    <td><?php echo $le->time_get;?></td>
                    <td><?php echo $le->time_use;?></td>
                    <td><?php echo $le->gift;?></td>
                    <td><?php echo $le->restaurant;?></td>
                    <td><?php echo $le->bills;?></td>
					<td><?php echo $le->customers;?></td>
					<td><?php echo number_format($le->revenue);?></td>
                </tr>
            <?php $i++; endforeach;?>
            <?php endif?>
            </tbody>
        </table>
        <div class="dataTables_info" id="dyntable_info">
            <div class="pagination">
                <?php echo $this->pagination->create_links();?> 
            </div>
        </div>
    </div>
</div>

<div id="hideReportgiftcode" style="display: none;"></div>
<style>
.table th, .table td {
vertical-align: middle !important;
}
</style>

<script type="text/javascript">
    $(document).ready(function(){
        $('#report').on('click', function(){
            $.ajax({
               type: "GET",
               url: baseUrl+'manage/campaign/reportgiftcode',
               data: ({'restaurant_id': $('#restaurant_id').val}),
               beforeSend: function(){
                    showPreload();
               },
               success: function(n){
                    $('#hideReportgiftcode').html(n);
                    exportToExcel();
               }  
            });
        });
        $('#restaurant_id').on('change', function(){
            var id = $(this).val();
            if(id != null && id != '' && id != 0)
            {
                window.location = baseUrl+'manage/campaign/report-gift-code?restaurant_id='+id;   
            }else{
                window.location = baseUrl+'manage/campaign/report-gift-code';
            }
        });
    });
</script>